cmake_minimum_required(VERSION 3.1)

project(wotermall)

SET(CMAKE_EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_EXECUTABLE_OUTPUT_PATH_DEBUG ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_EXECUTABLE_OUTPUT_PATH_RELEASE ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_PATH_DEBUG ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_PATH_RELEASE ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin)

set(CMAKE_DEBUG_POSTFIX "d")

# build qterm item to a static or shared libarary

set(KXTERM_ROOT_DIR ${PROJECT_SOURCE_DIR}/kxterm)
set(KXVNC_ROOT_DIR ${PROJECT_SOURCE_DIR}/kxvnc)
set(KXFTP_ROOT_DIR ${PROJECT_SOURCE_DIR}/kxftp)
set(KXUTIL_ROOT_DIR ${PROJECT_SOURCE_DIR}/kxutil)

if(WIN32)
    set(OPENSSL_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/openssl/winx)
    set(ZLIB_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/zlib/winx)
    set(LIBSSH_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/libssh/winx)
    set(LIBQSSH_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/qssh/winx)
    set(FREERDP_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/freerdp/winx)
    set(LIBOPENH264_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/openh264/winx)
    set(LIBPORTAUDIO_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/portaudio/winx)
    set(LIBOPUS_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/opus/winx)
    set(LIBJPEG_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/jpeg/winx)
    set(LIBYUV_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/libyuv/winx)
    set(LIBTELNET_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/libtelnet/winx)
    set(LIBMODEM_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/modem/winx)

    file(GLOB MY_COPY_FILES ${LIBSSH_ROOT_DIR}/bin/*.dll)
    file(GLOB MY_COPY_FILES ${MY_COPY_FILES} ${FREERDP_ROOT_DIR}/bin/*.dll)
    file(GLOB MY_COPY_FILES ${MY_COPY_FILES} ${OPENSSL_ROOT_DIR}/bin/*.dll)
else()
    set(OPENSSL_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/openssl/unix)
    set(ZLIB_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/zlib/unix)
    set(LIBSSH_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/libssh/unix)
    set(LIBQSSH_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/qssh/unix)
    set(FREERDP_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/freerdp/unix)
    set(LIBOPENH264_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/openh264/unix)
    set(LIBPORTAUDIO_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/portaudio/unix)
    set(LIBOPUS_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/opus/unix)
    set(LIBJPEG_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/jpeg/unix)
    set(LIBYUV_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/libyuv/unix)
    set(LIBTELNET_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/libtelnet/unix)
    set(LIBMODEM_ROOT_DIR ${PROJECT_SOURCE_DIR}/third/modem/unix)
    file(GLOB MY_COPY_FILES ${LIBSSH_ROOT_DIR}/lib/libssh.*)
    file(GLOB MY_COPY_FILES ${MY_COPY_FILES} ${FREERDP_ROOT_DIR}/lib/librdp.*)
    file(GLOB MY_COPY_FILES ${MY_COPY_FILES} ${OPENSSL_ROOT_DIR}/lib/lib*.dylib)
    file(GLOB MY_COPY_FILES ${MY_COPY_FILES} ${OPENSSL_ROOT_DIR}/lib/lib*.so*)
endif()
file(COPY ${MY_COPY_FILES} DESTINATION ${PROJECT_SOURCE_DIR}/bin)


message("copy file list:${MY_COPY_FILES}")
message("root path:${PROJECT_SOURCE_DIR}")

add_subdirectory(kxterm)
add_subdirectory(kxvnc)
add_subdirectory(kxutil)
add_subdirectory(kxftp)
add_subdirectory(woterm)

